package com.kldy8.kldyw.find.service;

import com.kldy8.kldyw.release.util.ConstantData;
import com.kldy8.kldyw.release.util.JsonUtil;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Qun Chen on 2016/11/2 0002.
 * 附近的电影
 */
public class Store {
    private String storeId;//演员id
    private String name;//名称
    private String image;//图片
    private String time;//时间
    private int distance;//距离
    private String description;//描述
    private String url;

    /****
     * 解析列表
     *
     * @param json
     * @return
     */
    public static List<Store> parseActorList(String json) {
        List<Store> result = new ArrayList<>();
        try {
            String actorJson = JsonUtil.parseString(json, "store");
            JSONArray jsonArray = new JSONArray(actorJson);
            for (int i = 0; i < jsonArray.length(); i++) {
                result.add(new Store(jsonArray.get(i).toString()));
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
        return result;
    }

    /***
     * 解析json成对象
     *
     * @param json
     */
    public Store(String json) {
        try {
            storeId = JsonUtil.parseString(json, "store_id");
            name = JsonUtil.parseString(json, "name");
            image = JsonUtil.parseString(json, "image");
            time = JsonUtil.parseString(json, "appear_time");
            distance = JsonUtil.parseInt(json, "distance");
            description = JsonUtil.parseString(json, "description");
            url = JsonUtil.parseString(json, "url");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public String getImageUrl() {
        return ConstantData.URL_LOAD_IMG + image;
    }

    public String getStoreId() {
        return storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
